package com.czf.testmodule.annotation;

import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Arrays;

/**
 * @author zfChen
 * @create 2022/7/4 9:55
 */
public class TestReflection {

    public static void main(String[] args) {
        try {
            Class<?> student = Class.forName("com.czf.testmodule.annotation.Student");
            Field[] declaredFields = student.getDeclaredFields();
            Method study = student.getMethod("study", Integer.class);
            Object invoke = study.invoke(student.newInstance(),2);
            Arrays.stream(declaredFields).forEach(System.out::println);
            Method[] declaredMethods = student.getDeclaredMethods();
            Arrays.stream(declaredMethods).forEach(System.out::println);


        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
